#!/usr/bin/perl

use strict;

package main;

use Getopt::Long;
use Lunmgr ':all';
use Data::Dumper;

my %_opts;

GetOptions(\%_opts,
          "-help|h");

my @pathes = split(/,/, join(',', @ARGV));

exit if (@pathes == 0);

my @devices = ReadTable("/home/lunmgr/lunmgr.devtable");

foreach my $device (@devices) {
    if (grep {$_ eq $device->path} @pathes) {
        my $sddev = GetDevForUuid($device->uuid);

        LogDebug("Remove device" . $device);
        LogDebug("echo 1 > /sys/block/" . $sddev . "/device/delete");

        $device->set_uuid('XXX-REMOVED-XXX');
    }
}

WriteTable(@devices);

